# -*- coding: utf-8 -*-
# @Author: Lemongman

from utils.single import singleton


# 全局变量的定义
@singleton
class GlobalVariable(dict):
    def __init__(self, keys=None):
        dict.__init__(self)
        if keys:
            for key in keys:
                dict.__setitem__(self, key, None)

    def __getitem__(self, key):
        try:
            return dict.__getitem__(self, key)
        except KeyError:
            raise KeyError(f'找不到全局变量：{key}')


GLV = GlobalVariable()